package com.xxzuibang.day16.math类;

public class MathMethod {
    public static void main(String[] args) {
        //math常用方法
        //1.abs求绝对值
        int abs=Math.abs(-9);
        System.out.println(abs);//9
        //2.pow求幂
        double pow=Math.pow(2,4);
        System.out.println(pow);//16.0
        //3.ceil向上取整，转成double
        double ceil=Math.ceil(3.1);
        System.out.println(ceil);//4.0
        //4.floor向下取整，转成double
        double floor=Math.floor(3.9);
        System.out.println(floor);//3.0
        //5.round四舍五入＋0.5
        double round=Math.round(1.5);
        System.out.println(round);//2.0
        //6.random随机数
        //公式：(int)(a+Math.random()*(b-a+1))
        //求2-7之间的随机数,10个
        for (int i = 0; i <10 ; i++) {
            System.out.println((int)(2+Math.random()*(7-2+1)));
        }
        //7.min，max返回最大值，最小值
        int min=Math.min(1,10);
        int max=Math.max(1,10);
        System.out.println("min="+min);//1
        System.out.println("max="+max);//10

    }
}
